
_sanity:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
//#include "fs.h"


int
main(int argc, char *argv[])
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	83 e4 f0             	and    $0xfffffff0,%esp
   6:	57                   	push   %edi
   7:	56                   	push   %esi
   8:	53                   	push   %ebx
   9:	31 db                	xor    %ebx,%ebx
   b:	81 ec 34 01 00 00    	sub    $0x134,%esp
  11:	eb 0d                	jmp    20 <main+0x20>
  13:	90                   	nop
  14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
	int avgrtime=0;
	int avgttime=0;
	int counter;
	int ttime;

	for (i=0; i<30; i++){
  18:	83 c3 01             	add    $0x1,%ebx
  1b:	83 fb 1e             	cmp    $0x1e,%ebx
  1e:	74 40                	je     60 <main+0x60>
		if((pid=fork())==0) {
  20:	e8 ab 03 00 00       	call   3d0 <fork>
  25:	85 c0                	test   %eax,%eax
  27:	75 ef                	jne    18 <main+0x18>
			cid = i;
			if( (cid % 2) == 0){
  29:	f6 c3 01             	test   $0x1,%bl
  2c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  30:	0f 84 6a 01 00 00    	je     1a0 <main+0x1a0>
				nice();
  36:	31 f6                	xor    %esi,%esi
			}
			for (j=0; j< 500; j++){
  38:	83 c6 01             	add    $0x1,%esi
				printf(1,"My CID is: %d\n", cid);
  3b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  3f:	c7 44 24 04 b0 08 00 	movl   $0x8b0,0x4(%esp)
  46:	00 
  47:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  4e:	e8 dd 04 00 00       	call   530 <printf>
		if((pid=fork())==0) {
			cid = i;
			if( (cid % 2) == 0){
				nice();
			}
			for (j=0; j< 500; j++){
  53:	81 fe f4 01 00 00    	cmp    $0x1f4,%esi
  59:	75 dd                	jne    38 <main+0x38>
			ttime = wtimes[counter] + rtimes[counter];
			printf(1, "Waiting: %d , Running: %d , Turnaround: %d \n", wtimes[counter], rtimes[counter], ttime);
		}
		
    }    
  exit();
  5b:	e8 78 03 00 00       	call   3d8 <exit>
	int avgrtime=0;
	int avgttime=0;
	int counter;
	int ttime;

	for (i=0; i<30; i++){
  60:	31 ff                	xor    %edi,%edi
  62:	8d 9c 24 b0 00 00 00 	lea    0xb0(%esp),%ebx
  69:	8d 74 24 38          	lea    0x38(%esp),%esi
  6d:	8d 76 00             	lea    0x0(%esi),%esi
	}


	if (pid != 0){
		for (counter = 0; counter<30; counter++){
			wait2(&wtime, &rtime);
  70:	8d 84 24 28 01 00 00 	lea    0x128(%esp),%eax
  77:	89 44 24 04          	mov    %eax,0x4(%esp)
  7b:	8d 84 24 2c 01 00 00 	lea    0x12c(%esp),%eax
  82:	89 04 24             	mov    %eax,(%esp)
  85:	e8 ee 03 00 00       	call   478 <wait2>
			//printf(1, "wtime: %d ; rtime: %d\n", wtime1, rtime1);
			wtimes[counter] = wtime;
  8a:	8b 84 24 2c 01 00 00 	mov    0x12c(%esp),%eax
  91:	89 04 bb             	mov    %eax,(%ebx,%edi,4)
			rtimes[counter] = rtime;
  94:	8b 84 24 28 01 00 00 	mov    0x128(%esp),%eax
  9b:	89 04 be             	mov    %eax,(%esi,%edi,4)
		}
	}


	if (pid != 0){
		for (counter = 0; counter<30; counter++){
  9e:	83 c7 01             	add    $0x1,%edi
  a1:	83 ff 1e             	cmp    $0x1e,%edi
  a4:	75 ca                	jne    70 <main+0x70>
  a6:	31 c0                	xor    %eax,%eax
  a8:	31 c9                	xor    %ecx,%ecx
  aa:	c7 44 24 2c 00 00 00 	movl   $0x0,0x2c(%esp)
  b1:	00 
  b2:	c7 44 24 28 00 00 00 	movl   $0x0,0x28(%esp)
  b9:	00 
  ba:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
			
			//printf(1, "test %d waiting time: %d , %d\n", counter,wtimes[counter], rtimes[counter]);
		}
		
		for (counter = 0; counter<30; counter++){
			avgwtime = avgwtime + wtimes[counter];
  c0:	8b 14 83             	mov    (%ebx,%eax,4),%edx
			avgrtime = avgrtime + rtimes[counter];
  c3:	8b 3c 86             	mov    (%esi,%eax,4),%edi
			rtimes[counter] = rtime;
			
			//printf(1, "test %d waiting time: %d , %d\n", counter,wtimes[counter], rtimes[counter]);
		}
		
		for (counter = 0; counter<30; counter++){
  c6:	83 c0 01             	add    $0x1,%eax
			avgwtime = avgwtime + wtimes[counter];
			avgrtime = avgrtime + rtimes[counter];
  c9:	01 7c 24 28          	add    %edi,0x28(%esp)
			
			//printf(1, "test %d waiting time: %d , %d\n", counter,wtimes[counter], rtimes[counter]);
		}
		
		for (counter = 0; counter<30; counter++){
			avgwtime = avgwtime + wtimes[counter];
  cd:	01 d1                	add    %edx,%ecx
			avgrtime = avgrtime + rtimes[counter];
			avgttime = avgttime + rtimes[counter] + wtimes[counter];
  cf:	8d 14 17             	lea    (%edi,%edx,1),%edx
  d2:	01 54 24 2c          	add    %edx,0x2c(%esp)
			rtimes[counter] = rtime;
			
			//printf(1, "test %d waiting time: %d , %d\n", counter,wtimes[counter], rtimes[counter]);
		}
		
		for (counter = 0; counter<30; counter++){
  d6:	83 f8 1e             	cmp    $0x1e,%eax
  d9:	75 e5                	jne    c0 <main+0xc0>
		
		avgwtime = avgwtime / 30;
		avgrtime = avgrtime / 30;
		avgttime = avgttime / 30;
		
		printf(1, "Average waiting time: %d\n", avgwtime);
  db:	bf 89 88 88 88       	mov    $0x88888889,%edi
  e0:	89 c8                	mov    %ecx,%eax
  e2:	f7 ef                	imul   %edi
  e4:	c7 44 24 04 bf 08 00 	movl   $0x8bf,0x4(%esp)
  eb:	00 
  ec:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  f3:	01 ca                	add    %ecx,%edx
  f5:	c1 fa 04             	sar    $0x4,%edx
  f8:	c1 f9 1f             	sar    $0x1f,%ecx
  fb:	29 ca                	sub    %ecx,%edx
  fd:	89 54 24 08          	mov    %edx,0x8(%esp)
 101:	e8 2a 04 00 00       	call   530 <printf>
		printf(1, "Average running time: %d\n", avgrtime);
 106:	8b 44 24 28          	mov    0x28(%esp),%eax
 10a:	c7 44 24 04 d9 08 00 	movl   $0x8d9,0x4(%esp)
 111:	00 
 112:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 119:	f7 ef                	imul   %edi
 11b:	8b 44 24 28          	mov    0x28(%esp),%eax
 11f:	03 54 24 28          	add    0x28(%esp),%edx
 123:	c1 f8 1f             	sar    $0x1f,%eax
 126:	c1 fa 04             	sar    $0x4,%edx
 129:	29 c2                	sub    %eax,%edx
 12b:	89 54 24 08          	mov    %edx,0x8(%esp)
 12f:	e8 fc 03 00 00       	call   530 <printf>
		printf(1, "Average turnaround time: %d\n", avgttime);
 134:	8b 44 24 2c          	mov    0x2c(%esp),%eax
 138:	c7 44 24 04 f3 08 00 	movl   $0x8f3,0x4(%esp)
 13f:	00 
 140:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 147:	f7 ef                	imul   %edi
 149:	8b 44 24 2c          	mov    0x2c(%esp),%eax
 14d:	31 ff                	xor    %edi,%edi
 14f:	03 54 24 2c          	add    0x2c(%esp),%edx
 153:	c1 f8 1f             	sar    $0x1f,%eax
 156:	c1 fa 04             	sar    $0x4,%edx
 159:	29 c2                	sub    %eax,%edx
 15b:	89 54 24 08          	mov    %edx,0x8(%esp)
 15f:	e8 cc 03 00 00       	call   530 <printf>
 164:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
		
		for (counter = 0; counter<30; counter++){
			ttime = wtimes[counter] + rtimes[counter];
 168:	8b 04 bb             	mov    (%ebx,%edi,4),%eax
 16b:	8b 14 be             	mov    (%esi,%edi,4),%edx
		
		printf(1, "Average waiting time: %d\n", avgwtime);
		printf(1, "Average running time: %d\n", avgrtime);
		printf(1, "Average turnaround time: %d\n", avgttime);
		
		for (counter = 0; counter<30; counter++){
 16e:	83 c7 01             	add    $0x1,%edi
			ttime = wtimes[counter] + rtimes[counter];
			printf(1, "Waiting: %d , Running: %d , Turnaround: %d \n", wtimes[counter], rtimes[counter], ttime);
 171:	c7 44 24 04 10 09 00 	movl   $0x910,0x4(%esp)
 178:	00 
 179:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 180:	89 44 24 08          	mov    %eax,0x8(%esp)
 184:	8d 0c 02             	lea    (%edx,%eax,1),%ecx
 187:	89 4c 24 10          	mov    %ecx,0x10(%esp)
 18b:	89 54 24 0c          	mov    %edx,0xc(%esp)
 18f:	e8 9c 03 00 00       	call   530 <printf>
		
		printf(1, "Average waiting time: %d\n", avgwtime);
		printf(1, "Average running time: %d\n", avgrtime);
		printf(1, "Average turnaround time: %d\n", avgttime);
		
		for (counter = 0; counter<30; counter++){
 194:	83 ff 1e             	cmp    $0x1e,%edi
 197:	75 cf                	jne    168 <main+0x168>
			ttime = wtimes[counter] + rtimes[counter];
			printf(1, "Waiting: %d , Running: %d , Turnaround: %d \n", wtimes[counter], rtimes[counter], ttime);
		}
		
    }    
  exit();
 199:	e8 3a 02 00 00       	call   3d8 <exit>
 19e:	66 90                	xchg   %ax,%ax

	for (i=0; i<30; i++){
		if((pid=fork())==0) {
			cid = i;
			if( (cid % 2) == 0){
				nice();
 1a0:	e8 db 02 00 00       	call   480 <nice>
 1a5:	e9 8c fe ff ff       	jmp    36 <main+0x36>
 1aa:	90                   	nop
 1ab:	90                   	nop
 1ac:	90                   	nop
 1ad:	90                   	nop
 1ae:	90                   	nop
 1af:	90                   	nop

000001b0 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 1b0:	55                   	push   %ebp
 1b1:	31 d2                	xor    %edx,%edx
 1b3:	89 e5                	mov    %esp,%ebp
 1b5:	8b 45 08             	mov    0x8(%ebp),%eax
 1b8:	53                   	push   %ebx
 1b9:	8b 5d 0c             	mov    0xc(%ebp),%ebx
 1bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 1c0:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
 1c4:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 1c7:	83 c2 01             	add    $0x1,%edx
 1ca:	84 c9                	test   %cl,%cl
 1cc:	75 f2                	jne    1c0 <strcpy+0x10>
    ;
  return os;
}
 1ce:	5b                   	pop    %ebx
 1cf:	5d                   	pop    %ebp
 1d0:	c3                   	ret    
 1d1:	eb 0d                	jmp    1e0 <strcmp>
 1d3:	90                   	nop
 1d4:	90                   	nop
 1d5:	90                   	nop
 1d6:	90                   	nop
 1d7:	90                   	nop
 1d8:	90                   	nop
 1d9:	90                   	nop
 1da:	90                   	nop
 1db:	90                   	nop
 1dc:	90                   	nop
 1dd:	90                   	nop
 1de:	90                   	nop
 1df:	90                   	nop

000001e0 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 1e0:	55                   	push   %ebp
 1e1:	89 e5                	mov    %esp,%ebp
 1e3:	53                   	push   %ebx
 1e4:	8b 4d 08             	mov    0x8(%ebp),%ecx
 1e7:	8b 55 0c             	mov    0xc(%ebp),%edx
  while(*p && *p == *q)
 1ea:	0f b6 01             	movzbl (%ecx),%eax
 1ed:	84 c0                	test   %al,%al
 1ef:	75 14                	jne    205 <strcmp+0x25>
 1f1:	eb 25                	jmp    218 <strcmp+0x38>
 1f3:	90                   	nop
 1f4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    p++, q++;
 1f8:	83 c1 01             	add    $0x1,%ecx
 1fb:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 1fe:	0f b6 01             	movzbl (%ecx),%eax
 201:	84 c0                	test   %al,%al
 203:	74 13                	je     218 <strcmp+0x38>
 205:	0f b6 1a             	movzbl (%edx),%ebx
 208:	38 d8                	cmp    %bl,%al
 20a:	74 ec                	je     1f8 <strcmp+0x18>
 20c:	0f b6 db             	movzbl %bl,%ebx
 20f:	0f b6 c0             	movzbl %al,%eax
 212:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
 214:	5b                   	pop    %ebx
 215:	5d                   	pop    %ebp
 216:	c3                   	ret    
 217:	90                   	nop
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 218:	0f b6 1a             	movzbl (%edx),%ebx
 21b:	31 c0                	xor    %eax,%eax
 21d:	0f b6 db             	movzbl %bl,%ebx
 220:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
 222:	5b                   	pop    %ebx
 223:	5d                   	pop    %ebp
 224:	c3                   	ret    
 225:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 229:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000230 <strlen>:

uint
strlen(char *s)
{
 230:	55                   	push   %ebp
  int n;

  for(n = 0; s[n]; n++)
 231:	31 d2                	xor    %edx,%edx
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
 233:	89 e5                	mov    %esp,%ebp
  int n;

  for(n = 0; s[n]; n++)
 235:	31 c0                	xor    %eax,%eax
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
 237:	8b 4d 08             	mov    0x8(%ebp),%ecx
  int n;

  for(n = 0; s[n]; n++)
 23a:	80 39 00             	cmpb   $0x0,(%ecx)
 23d:	74 0c                	je     24b <strlen+0x1b>
 23f:	90                   	nop
 240:	83 c2 01             	add    $0x1,%edx
 243:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
 247:	89 d0                	mov    %edx,%eax
 249:	75 f5                	jne    240 <strlen+0x10>
    ;
  return n;
}
 24b:	5d                   	pop    %ebp
 24c:	c3                   	ret    
 24d:	8d 76 00             	lea    0x0(%esi),%esi

00000250 <memset>:

void*
memset(void *dst, int c, uint n)
{
 250:	55                   	push   %ebp
 251:	89 e5                	mov    %esp,%ebp
 253:	8b 55 08             	mov    0x8(%ebp),%edx
 256:	57                   	push   %edi
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
 257:	8b 4d 10             	mov    0x10(%ebp),%ecx
 25a:	8b 45 0c             	mov    0xc(%ebp),%eax
 25d:	89 d7                	mov    %edx,%edi
 25f:	fc                   	cld    
 260:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
 262:	89 d0                	mov    %edx,%eax
 264:	5f                   	pop    %edi
 265:	5d                   	pop    %ebp
 266:	c3                   	ret    
 267:	89 f6                	mov    %esi,%esi
 269:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000270 <strchr>:

char*
strchr(const char *s, char c)
{
 270:	55                   	push   %ebp
 271:	89 e5                	mov    %esp,%ebp
 273:	8b 45 08             	mov    0x8(%ebp),%eax
 276:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  for(; *s; s++)
 27a:	0f b6 10             	movzbl (%eax),%edx
 27d:	84 d2                	test   %dl,%dl
 27f:	75 11                	jne    292 <strchr+0x22>
 281:	eb 15                	jmp    298 <strchr+0x28>
 283:	90                   	nop
 284:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 288:	83 c0 01             	add    $0x1,%eax
 28b:	0f b6 10             	movzbl (%eax),%edx
 28e:	84 d2                	test   %dl,%dl
 290:	74 06                	je     298 <strchr+0x28>
    if(*s == c)
 292:	38 ca                	cmp    %cl,%dl
 294:	75 f2                	jne    288 <strchr+0x18>
      return (char*) s;
  return 0;
}
 296:	5d                   	pop    %ebp
 297:	c3                   	ret    
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 298:	31 c0                	xor    %eax,%eax
    if(*s == c)
      return (char*) s;
  return 0;
}
 29a:	5d                   	pop    %ebp
 29b:	90                   	nop
 29c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 2a0:	c3                   	ret    
 2a1:	eb 0d                	jmp    2b0 <atoi>
 2a3:	90                   	nop
 2a4:	90                   	nop
 2a5:	90                   	nop
 2a6:	90                   	nop
 2a7:	90                   	nop
 2a8:	90                   	nop
 2a9:	90                   	nop
 2aa:	90                   	nop
 2ab:	90                   	nop
 2ac:	90                   	nop
 2ad:	90                   	nop
 2ae:	90                   	nop
 2af:	90                   	nop

000002b0 <atoi>:
  return r;
}

int
atoi(const char *s)
{
 2b0:	55                   	push   %ebp
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 2b1:	31 c0                	xor    %eax,%eax
  return r;
}

int
atoi(const char *s)
{
 2b3:	89 e5                	mov    %esp,%ebp
 2b5:	8b 4d 08             	mov    0x8(%ebp),%ecx
 2b8:	53                   	push   %ebx
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 2b9:	0f b6 11             	movzbl (%ecx),%edx
 2bc:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2bf:	80 fb 09             	cmp    $0x9,%bl
 2c2:	77 1c                	ja     2e0 <atoi+0x30>
 2c4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    n = n*10 + *s++ - '0';
 2c8:	0f be d2             	movsbl %dl,%edx
 2cb:	83 c1 01             	add    $0x1,%ecx
 2ce:	8d 04 80             	lea    (%eax,%eax,4),%eax
 2d1:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 2d5:	0f b6 11             	movzbl (%ecx),%edx
 2d8:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2db:	80 fb 09             	cmp    $0x9,%bl
 2de:	76 e8                	jbe    2c8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
 2e0:	5b                   	pop    %ebx
 2e1:	5d                   	pop    %ebp
 2e2:	c3                   	ret    
 2e3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 2e9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000002f0 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 2f0:	55                   	push   %ebp
 2f1:	89 e5                	mov    %esp,%ebp
 2f3:	56                   	push   %esi
 2f4:	8b 45 08             	mov    0x8(%ebp),%eax
 2f7:	53                   	push   %ebx
 2f8:	8b 5d 10             	mov    0x10(%ebp),%ebx
 2fb:	8b 75 0c             	mov    0xc(%ebp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 2fe:	85 db                	test   %ebx,%ebx
 300:	7e 14                	jle    316 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
 302:	31 d2                	xor    %edx,%edx
 304:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
 308:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 30c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 30f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 312:	39 da                	cmp    %ebx,%edx
 314:	75 f2                	jne    308 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
 316:	5b                   	pop    %ebx
 317:	5e                   	pop    %esi
 318:	5d                   	pop    %ebp
 319:	c3                   	ret    
 31a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00000320 <stat>:
  return buf;
}

int
stat(char *n, struct stat *st)
{
 320:	55                   	push   %ebp
 321:	89 e5                	mov    %esp,%ebp
 323:	83 ec 18             	sub    $0x18,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 326:	8b 45 08             	mov    0x8(%ebp),%eax
  return buf;
}

int
stat(char *n, struct stat *st)
{
 329:	89 5d f8             	mov    %ebx,-0x8(%ebp)
 32c:	89 75 fc             	mov    %esi,-0x4(%ebp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
 32f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 334:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 33b:	00 
 33c:	89 04 24             	mov    %eax,(%esp)
 33f:	e8 d4 00 00 00       	call   418 <open>
  if(fd < 0)
 344:	85 c0                	test   %eax,%eax
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 346:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
 348:	78 19                	js     363 <stat+0x43>
    return -1;
  r = fstat(fd, st);
 34a:	8b 45 0c             	mov    0xc(%ebp),%eax
 34d:	89 1c 24             	mov    %ebx,(%esp)
 350:	89 44 24 04          	mov    %eax,0x4(%esp)
 354:	e8 d7 00 00 00       	call   430 <fstat>
  close(fd);
 359:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
 35c:	89 c6                	mov    %eax,%esi
  close(fd);
 35e:	e8 9d 00 00 00       	call   400 <close>
  return r;
}
 363:	89 f0                	mov    %esi,%eax
 365:	8b 5d f8             	mov    -0x8(%ebp),%ebx
 368:	8b 75 fc             	mov    -0x4(%ebp),%esi
 36b:	89 ec                	mov    %ebp,%esp
 36d:	5d                   	pop    %ebp
 36e:	c3                   	ret    
 36f:	90                   	nop

00000370 <gets>:
  return 0;
}

char*
gets(char *buf, int max)
{
 370:	55                   	push   %ebp
 371:	89 e5                	mov    %esp,%ebp
 373:	57                   	push   %edi
 374:	56                   	push   %esi
 375:	31 f6                	xor    %esi,%esi
 377:	53                   	push   %ebx
 378:	83 ec 2c             	sub    $0x2c,%esp
 37b:	8b 7d 08             	mov    0x8(%ebp),%edi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 37e:	eb 06                	jmp    386 <gets+0x16>
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 380:	3c 0a                	cmp    $0xa,%al
 382:	74 39                	je     3bd <gets+0x4d>
 384:	89 de                	mov    %ebx,%esi
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 386:	8d 5e 01             	lea    0x1(%esi),%ebx
 389:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
 38c:	7d 31                	jge    3bf <gets+0x4f>
    cc = read(0, &c, 1);
 38e:	8d 45 e7             	lea    -0x19(%ebp),%eax
 391:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 398:	00 
 399:	89 44 24 04          	mov    %eax,0x4(%esp)
 39d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 3a4:	e8 47 00 00 00       	call   3f0 <read>
    if(cc < 1)
 3a9:	85 c0                	test   %eax,%eax
 3ab:	7e 12                	jle    3bf <gets+0x4f>
      break;
    buf[i++] = c;
 3ad:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
 3b1:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
 3b5:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
 3b9:	3c 0d                	cmp    $0xd,%al
 3bb:	75 c3                	jne    380 <gets+0x10>
 3bd:	89 de                	mov    %ebx,%esi
      break;
  }
  buf[i] = '\0';
 3bf:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
 3c3:	89 f8                	mov    %edi,%eax
 3c5:	83 c4 2c             	add    $0x2c,%esp
 3c8:	5b                   	pop    %ebx
 3c9:	5e                   	pop    %esi
 3ca:	5f                   	pop    %edi
 3cb:	5d                   	pop    %ebp
 3cc:	c3                   	ret    
 3cd:	90                   	nop
 3ce:	90                   	nop
 3cf:	90                   	nop

000003d0 <fork>:
  name: \
    movl $SYS_ ## name, %eax; \
    int $T_SYSCALL; \
    ret

SYSCALL(fork)
 3d0:	b8 01 00 00 00       	mov    $0x1,%eax
 3d5:	cd 40                	int    $0x40
 3d7:	c3                   	ret    

000003d8 <exit>:
SYSCALL(exit)
 3d8:	b8 02 00 00 00       	mov    $0x2,%eax
 3dd:	cd 40                	int    $0x40
 3df:	c3                   	ret    

000003e0 <wait>:
SYSCALL(wait)
 3e0:	b8 03 00 00 00       	mov    $0x3,%eax
 3e5:	cd 40                	int    $0x40
 3e7:	c3                   	ret    

000003e8 <pipe>:
SYSCALL(pipe)
 3e8:	b8 04 00 00 00       	mov    $0x4,%eax
 3ed:	cd 40                	int    $0x40
 3ef:	c3                   	ret    

000003f0 <read>:
SYSCALL(read)
 3f0:	b8 06 00 00 00       	mov    $0x6,%eax
 3f5:	cd 40                	int    $0x40
 3f7:	c3                   	ret    

000003f8 <write>:
SYSCALL(write)
 3f8:	b8 05 00 00 00       	mov    $0x5,%eax
 3fd:	cd 40                	int    $0x40
 3ff:	c3                   	ret    

00000400 <close>:
SYSCALL(close)
 400:	b8 07 00 00 00       	mov    $0x7,%eax
 405:	cd 40                	int    $0x40
 407:	c3                   	ret    

00000408 <kill>:
SYSCALL(kill)
 408:	b8 08 00 00 00       	mov    $0x8,%eax
 40d:	cd 40                	int    $0x40
 40f:	c3                   	ret    

00000410 <exec>:
SYSCALL(exec)
 410:	b8 09 00 00 00       	mov    $0x9,%eax
 415:	cd 40                	int    $0x40
 417:	c3                   	ret    

00000418 <open>:
SYSCALL(open)
 418:	b8 0a 00 00 00       	mov    $0xa,%eax
 41d:	cd 40                	int    $0x40
 41f:	c3                   	ret    

00000420 <mknod>:
SYSCALL(mknod)
 420:	b8 0b 00 00 00       	mov    $0xb,%eax
 425:	cd 40                	int    $0x40
 427:	c3                   	ret    

00000428 <unlink>:
SYSCALL(unlink)
 428:	b8 0c 00 00 00       	mov    $0xc,%eax
 42d:	cd 40                	int    $0x40
 42f:	c3                   	ret    

00000430 <fstat>:
SYSCALL(fstat)
 430:	b8 0d 00 00 00       	mov    $0xd,%eax
 435:	cd 40                	int    $0x40
 437:	c3                   	ret    

00000438 <link>:
SYSCALL(link)
 438:	b8 0e 00 00 00       	mov    $0xe,%eax
 43d:	cd 40                	int    $0x40
 43f:	c3                   	ret    

00000440 <mkdir>:
SYSCALL(mkdir)
 440:	b8 0f 00 00 00       	mov    $0xf,%eax
 445:	cd 40                	int    $0x40
 447:	c3                   	ret    

00000448 <chdir>:
SYSCALL(chdir)
 448:	b8 10 00 00 00       	mov    $0x10,%eax
 44d:	cd 40                	int    $0x40
 44f:	c3                   	ret    

00000450 <dup>:
SYSCALL(dup)
 450:	b8 11 00 00 00       	mov    $0x11,%eax
 455:	cd 40                	int    $0x40
 457:	c3                   	ret    

00000458 <getpid>:
SYSCALL(getpid)
 458:	b8 12 00 00 00       	mov    $0x12,%eax
 45d:	cd 40                	int    $0x40
 45f:	c3                   	ret    

00000460 <sbrk>:
SYSCALL(sbrk)
 460:	b8 13 00 00 00       	mov    $0x13,%eax
 465:	cd 40                	int    $0x40
 467:	c3                   	ret    

00000468 <sleep>:
SYSCALL(sleep)
 468:	b8 14 00 00 00       	mov    $0x14,%eax
 46d:	cd 40                	int    $0x40
 46f:	c3                   	ret    

00000470 <uptime>:
SYSCALL(uptime)
 470:	b8 15 00 00 00       	mov    $0x15,%eax
 475:	cd 40                	int    $0x40
 477:	c3                   	ret    

00000478 <wait2>:
SYSCALL(wait2)
 478:	b8 16 00 00 00       	mov    $0x16,%eax
 47d:	cd 40                	int    $0x40
 47f:	c3                   	ret    

00000480 <nice>:
SYSCALL(nice)
 480:	b8 17 00 00 00       	mov    $0x17,%eax
 485:	cd 40                	int    $0x40
 487:	c3                   	ret    
 488:	90                   	nop
 489:	90                   	nop
 48a:	90                   	nop
 48b:	90                   	nop
 48c:	90                   	nop
 48d:	90                   	nop
 48e:	90                   	nop
 48f:	90                   	nop

00000490 <printint>:
  write(fd, &c, 1);
}

static void
printint(int fd, int xx, int base, int sgn)
{
 490:	55                   	push   %ebp
 491:	89 e5                	mov    %esp,%ebp
 493:	57                   	push   %edi
 494:	89 cf                	mov    %ecx,%edi
 496:	56                   	push   %esi
 497:	89 c6                	mov    %eax,%esi
 499:	53                   	push   %ebx
 49a:	83 ec 4c             	sub    $0x4c,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 49d:	8b 4d 08             	mov    0x8(%ebp),%ecx
 4a0:	85 c9                	test   %ecx,%ecx
 4a2:	74 04                	je     4a8 <printint+0x18>
 4a4:	85 d2                	test   %edx,%edx
 4a6:	78 70                	js     518 <printint+0x88>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 4a8:	89 d0                	mov    %edx,%eax
 4aa:	c7 45 c4 00 00 00 00 	movl   $0x0,-0x3c(%ebp)
 4b1:	31 c9                	xor    %ecx,%ecx
 4b3:	8d 5d d7             	lea    -0x29(%ebp),%ebx
 4b6:	66 90                	xchg   %ax,%ax
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 4b8:	31 d2                	xor    %edx,%edx
 4ba:	f7 f7                	div    %edi
 4bc:	0f b6 92 47 09 00 00 	movzbl 0x947(%edx),%edx
 4c3:	88 14 0b             	mov    %dl,(%ebx,%ecx,1)
 4c6:	83 c1 01             	add    $0x1,%ecx
  }while((x /= base) != 0);
 4c9:	85 c0                	test   %eax,%eax
 4cb:	75 eb                	jne    4b8 <printint+0x28>
  if(neg)
 4cd:	8b 45 c4             	mov    -0x3c(%ebp),%eax
 4d0:	85 c0                	test   %eax,%eax
 4d2:	74 08                	je     4dc <printint+0x4c>
    buf[i++] = '-';
 4d4:	c6 44 0d d7 2d       	movb   $0x2d,-0x29(%ebp,%ecx,1)
 4d9:	83 c1 01             	add    $0x1,%ecx

  while(--i >= 0)
 4dc:	8d 79 ff             	lea    -0x1(%ecx),%edi
 4df:	01 fb                	add    %edi,%ebx
 4e1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 4e8:	0f b6 03             	movzbl (%ebx),%eax
 4eb:	83 ef 01             	sub    $0x1,%edi
 4ee:	83 eb 01             	sub    $0x1,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 4f1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 4f8:	00 
 4f9:	89 34 24             	mov    %esi,(%esp)
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 4fc:	88 45 e7             	mov    %al,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 4ff:	8d 45 e7             	lea    -0x19(%ebp),%eax
 502:	89 44 24 04          	mov    %eax,0x4(%esp)
 506:	e8 ed fe ff ff       	call   3f8 <write>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 50b:	83 ff ff             	cmp    $0xffffffff,%edi
 50e:	75 d8                	jne    4e8 <printint+0x58>
    putc(fd, buf[i]);
}
 510:	83 c4 4c             	add    $0x4c,%esp
 513:	5b                   	pop    %ebx
 514:	5e                   	pop    %esi
 515:	5f                   	pop    %edi
 516:	5d                   	pop    %ebp
 517:	c3                   	ret    
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
 518:	89 d0                	mov    %edx,%eax
 51a:	f7 d8                	neg    %eax
 51c:	c7 45 c4 01 00 00 00 	movl   $0x1,-0x3c(%ebp)
 523:	eb 8c                	jmp    4b1 <printint+0x21>
 525:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 529:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000530 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 530:	55                   	push   %ebp
 531:	89 e5                	mov    %esp,%ebp
 533:	57                   	push   %edi
 534:	56                   	push   %esi
 535:	53                   	push   %ebx
 536:	83 ec 3c             	sub    $0x3c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 539:	8b 45 0c             	mov    0xc(%ebp),%eax
 53c:	0f b6 10             	movzbl (%eax),%edx
 53f:	84 d2                	test   %dl,%dl
 541:	0f 84 c9 00 00 00    	je     610 <printf+0xe0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
 547:	8d 4d 10             	lea    0x10(%ebp),%ecx
 54a:	31 ff                	xor    %edi,%edi
 54c:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
 54f:	31 db                	xor    %ebx,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 551:	8d 75 e7             	lea    -0x19(%ebp),%esi
 554:	eb 1e                	jmp    574 <printf+0x44>
 556:	66 90                	xchg   %ax,%ax
  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 558:	83 fa 25             	cmp    $0x25,%edx
 55b:	0f 85 b7 00 00 00    	jne    618 <printf+0xe8>
 561:	66 bf 25 00          	mov    $0x25,%di
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 565:	83 c3 01             	add    $0x1,%ebx
 568:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
 56c:	84 d2                	test   %dl,%dl
 56e:	0f 84 9c 00 00 00    	je     610 <printf+0xe0>
    c = fmt[i] & 0xff;
    if(state == 0){
 574:	85 ff                	test   %edi,%edi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
 576:	0f b6 d2             	movzbl %dl,%edx
    if(state == 0){
 579:	74 dd                	je     558 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 57b:	83 ff 25             	cmp    $0x25,%edi
 57e:	75 e5                	jne    565 <printf+0x35>
      if(c == 'd'){
 580:	83 fa 64             	cmp    $0x64,%edx
 583:	0f 84 57 01 00 00    	je     6e0 <printf+0x1b0>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 589:	83 fa 70             	cmp    $0x70,%edx
 58c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 590:	0f 84 aa 00 00 00    	je     640 <printf+0x110>
 596:	83 fa 78             	cmp    $0x78,%edx
 599:	0f 84 a1 00 00 00    	je     640 <printf+0x110>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 59f:	83 fa 73             	cmp    $0x73,%edx
 5a2:	0f 84 c0 00 00 00    	je     668 <printf+0x138>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 5a8:	83 fa 63             	cmp    $0x63,%edx
 5ab:	90                   	nop
 5ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 5b0:	0f 84 52 01 00 00    	je     708 <printf+0x1d8>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 5b6:	83 fa 25             	cmp    $0x25,%edx
 5b9:	0f 84 f9 00 00 00    	je     6b8 <printf+0x188>
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 5bf:	8b 4d 08             	mov    0x8(%ebp),%ecx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 5c2:	83 c3 01             	add    $0x1,%ebx
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 5c5:	31 ff                	xor    %edi,%edi
 5c7:	89 55 cc             	mov    %edx,-0x34(%ebp)
 5ca:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
 5ce:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 5d5:	00 
 5d6:	89 0c 24             	mov    %ecx,(%esp)
 5d9:	89 74 24 04          	mov    %esi,0x4(%esp)
 5dd:	e8 16 fe ff ff       	call   3f8 <write>
 5e2:	8b 55 cc             	mov    -0x34(%ebp),%edx
 5e5:	8b 45 08             	mov    0x8(%ebp),%eax
 5e8:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 5ef:	00 
 5f0:	89 74 24 04          	mov    %esi,0x4(%esp)
 5f4:	88 55 e7             	mov    %dl,-0x19(%ebp)
 5f7:	89 04 24             	mov    %eax,(%esp)
 5fa:	e8 f9 fd ff ff       	call   3f8 <write>
 5ff:	8b 45 0c             	mov    0xc(%ebp),%eax
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 602:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
 606:	84 d2                	test   %dl,%dl
 608:	0f 85 66 ff ff ff    	jne    574 <printf+0x44>
 60e:	66 90                	xchg   %ax,%ax
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 610:	83 c4 3c             	add    $0x3c,%esp
 613:	5b                   	pop    %ebx
 614:	5e                   	pop    %esi
 615:	5f                   	pop    %edi
 616:	5d                   	pop    %ebp
 617:	c3                   	ret    
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 618:	8b 45 08             	mov    0x8(%ebp),%eax
  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 61b:	88 55 e7             	mov    %dl,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 61e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 625:	00 
 626:	89 74 24 04          	mov    %esi,0x4(%esp)
 62a:	89 04 24             	mov    %eax,(%esp)
 62d:	e8 c6 fd ff ff       	call   3f8 <write>
 632:	8b 45 0c             	mov    0xc(%ebp),%eax
 635:	e9 2b ff ff ff       	jmp    565 <printf+0x35>
 63a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 640:	8b 45 d4             	mov    -0x2c(%ebp),%eax
 643:	b9 10 00 00 00       	mov    $0x10,%ecx
        ap++;
 648:	31 ff                	xor    %edi,%edi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 64a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 651:	8b 10                	mov    (%eax),%edx
 653:	8b 45 08             	mov    0x8(%ebp),%eax
 656:	e8 35 fe ff ff       	call   490 <printint>
 65b:	8b 45 0c             	mov    0xc(%ebp),%eax
        ap++;
 65e:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
 662:	e9 fe fe ff ff       	jmp    565 <printf+0x35>
 667:	90                   	nop
      } else if(c == 's'){
        s = (char*)*ap;
 668:	8b 55 d4             	mov    -0x2c(%ebp),%edx
 66b:	8b 3a                	mov    (%edx),%edi
        ap++;
 66d:	83 c2 04             	add    $0x4,%edx
 670:	89 55 d4             	mov    %edx,-0x2c(%ebp)
        if(s == 0)
 673:	85 ff                	test   %edi,%edi
 675:	0f 84 ba 00 00 00    	je     735 <printf+0x205>
          s = "(null)";
        while(*s != 0){
 67b:	0f b6 17             	movzbl (%edi),%edx
 67e:	84 d2                	test   %dl,%dl
 680:	74 2d                	je     6af <printf+0x17f>
 682:	89 5d d0             	mov    %ebx,-0x30(%ebp)
 685:	8b 5d 08             	mov    0x8(%ebp),%ebx
          putc(fd, *s);
          s++;
 688:	83 c7 01             	add    $0x1,%edi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 68b:	88 55 e7             	mov    %dl,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 68e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 695:	00 
 696:	89 74 24 04          	mov    %esi,0x4(%esp)
 69a:	89 1c 24             	mov    %ebx,(%esp)
 69d:	e8 56 fd ff ff       	call   3f8 <write>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 6a2:	0f b6 17             	movzbl (%edi),%edx
 6a5:	84 d2                	test   %dl,%dl
 6a7:	75 df                	jne    688 <printf+0x158>
 6a9:	8b 5d d0             	mov    -0x30(%ebp),%ebx
 6ac:	8b 45 0c             	mov    0xc(%ebp),%eax
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 6af:	31 ff                	xor    %edi,%edi
 6b1:	e9 af fe ff ff       	jmp    565 <printf+0x35>
 6b6:	66 90                	xchg   %ax,%ax
 6b8:	8b 55 08             	mov    0x8(%ebp),%edx
 6bb:	31 ff                	xor    %edi,%edi
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 6bd:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 6c1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 6c8:	00 
 6c9:	89 74 24 04          	mov    %esi,0x4(%esp)
 6cd:	89 14 24             	mov    %edx,(%esp)
 6d0:	e8 23 fd ff ff       	call   3f8 <write>
 6d5:	8b 45 0c             	mov    0xc(%ebp),%eax
 6d8:	e9 88 fe ff ff       	jmp    565 <printf+0x35>
 6dd:	8d 76 00             	lea    0x0(%esi),%esi
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 6e0:	8b 45 d4             	mov    -0x2c(%ebp),%eax
 6e3:	b9 0a 00 00 00       	mov    $0xa,%ecx
        ap++;
 6e8:	66 31 ff             	xor    %di,%di
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 6eb:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 6f2:	8b 10                	mov    (%eax),%edx
 6f4:	8b 45 08             	mov    0x8(%ebp),%eax
 6f7:	e8 94 fd ff ff       	call   490 <printint>
 6fc:	8b 45 0c             	mov    0xc(%ebp),%eax
        ap++;
 6ff:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
 703:	e9 5d fe ff ff       	jmp    565 <printf+0x35>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 708:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
        putc(fd, *ap);
        ap++;
 70b:	31 ff                	xor    %edi,%edi
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 70d:	8b 01                	mov    (%ecx),%eax
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 70f:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 716:	00 
 717:	89 74 24 04          	mov    %esi,0x4(%esp)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 71b:	88 45 e7             	mov    %al,-0x19(%ebp)
#include "user.h"

static void
putc(int fd, char c)
{
  write(fd, &c, 1);
 71e:	8b 45 08             	mov    0x8(%ebp),%eax
 721:	89 04 24             	mov    %eax,(%esp)
 724:	e8 cf fc ff ff       	call   3f8 <write>
 729:	8b 45 0c             	mov    0xc(%ebp),%eax
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
 72c:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
 730:	e9 30 fe ff ff       	jmp    565 <printf+0x35>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
 735:	bf 40 09 00 00       	mov    $0x940,%edi
 73a:	e9 3c ff ff ff       	jmp    67b <printf+0x14b>
 73f:	90                   	nop

00000740 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 740:	55                   	push   %ebp
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 741:	a1 60 09 00 00       	mov    0x960,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
 746:	89 e5                	mov    %esp,%ebp
 748:	57                   	push   %edi
 749:	56                   	push   %esi
 74a:	53                   	push   %ebx
 74b:	8b 5d 08             	mov    0x8(%ebp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
 74e:	8d 4b f8             	lea    -0x8(%ebx),%ecx
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 751:	39 c8                	cmp    %ecx,%eax
 753:	73 1d                	jae    772 <free+0x32>
 755:	8d 76 00             	lea    0x0(%esi),%esi
 758:	8b 10                	mov    (%eax),%edx
 75a:	39 d1                	cmp    %edx,%ecx
 75c:	72 1a                	jb     778 <free+0x38>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 75e:	39 d0                	cmp    %edx,%eax
 760:	72 08                	jb     76a <free+0x2a>
 762:	39 c8                	cmp    %ecx,%eax
 764:	72 12                	jb     778 <free+0x38>
 766:	39 d1                	cmp    %edx,%ecx
 768:	72 0e                	jb     778 <free+0x38>
 76a:	89 d0                	mov    %edx,%eax
free(void *ap)
{
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 76c:	39 c8                	cmp    %ecx,%eax
 76e:	66 90                	xchg   %ax,%ax
 770:	72 e6                	jb     758 <free+0x18>
 772:	8b 10                	mov    (%eax),%edx
 774:	eb e8                	jmp    75e <free+0x1e>
 776:	66 90                	xchg   %ax,%ax
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 778:	8b 71 04             	mov    0x4(%ecx),%esi
 77b:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 77e:	39 d7                	cmp    %edx,%edi
 780:	74 19                	je     79b <free+0x5b>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 782:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
 785:	8b 50 04             	mov    0x4(%eax),%edx
 788:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 78b:	39 ce                	cmp    %ecx,%esi
 78d:	74 23                	je     7b2 <free+0x72>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 78f:	89 08                	mov    %ecx,(%eax)
  freep = p;
 791:	a3 60 09 00 00       	mov    %eax,0x960
}
 796:	5b                   	pop    %ebx
 797:	5e                   	pop    %esi
 798:	5f                   	pop    %edi
 799:	5d                   	pop    %ebp
 79a:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 79b:	03 72 04             	add    0x4(%edx),%esi
 79e:	89 71 04             	mov    %esi,0x4(%ecx)
    bp->s.ptr = p->s.ptr->s.ptr;
 7a1:	8b 10                	mov    (%eax),%edx
 7a3:	8b 12                	mov    (%edx),%edx
 7a5:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
 7a8:	8b 50 04             	mov    0x4(%eax),%edx
 7ab:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 7ae:	39 ce                	cmp    %ecx,%esi
 7b0:	75 dd                	jne    78f <free+0x4f>
    p->s.size += bp->s.size;
 7b2:	03 51 04             	add    0x4(%ecx),%edx
 7b5:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 7b8:	8b 53 f8             	mov    -0x8(%ebx),%edx
 7bb:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
 7bd:	a3 60 09 00 00       	mov    %eax,0x960
}
 7c2:	5b                   	pop    %ebx
 7c3:	5e                   	pop    %esi
 7c4:	5f                   	pop    %edi
 7c5:	5d                   	pop    %ebp
 7c6:	c3                   	ret    
 7c7:	89 f6                	mov    %esi,%esi
 7c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000007d0 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 7d0:	55                   	push   %ebp
 7d1:	89 e5                	mov    %esp,%ebp
 7d3:	57                   	push   %edi
 7d4:	56                   	push   %esi
 7d5:	53                   	push   %ebx
 7d6:	83 ec 1c             	sub    $0x1c,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 7d9:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if((prevp = freep) == 0){
 7dc:	8b 0d 60 09 00 00    	mov    0x960,%ecx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 7e2:	83 c3 07             	add    $0x7,%ebx
 7e5:	c1 eb 03             	shr    $0x3,%ebx
 7e8:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
 7eb:	85 c9                	test   %ecx,%ecx
 7ed:	0f 84 93 00 00 00    	je     886 <malloc+0xb6>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 7f3:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
 7f5:	8b 50 04             	mov    0x4(%eax),%edx
 7f8:	39 d3                	cmp    %edx,%ebx
 7fa:	76 1f                	jbe    81b <malloc+0x4b>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 7fc:	8d 34 dd 00 00 00 00 	lea    0x0(,%ebx,8),%esi
 803:	90                   	nop
 804:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    }
    if(p == freep)
 808:	3b 05 60 09 00 00    	cmp    0x960,%eax
 80e:	74 30                	je     840 <malloc+0x70>
 810:	89 c1                	mov    %eax,%ecx
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 812:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
 814:	8b 50 04             	mov    0x4(%eax),%edx
 817:	39 d3                	cmp    %edx,%ebx
 819:	77 ed                	ja     808 <malloc+0x38>
      if(p->s.size == nunits)
 81b:	39 d3                	cmp    %edx,%ebx
 81d:	74 61                	je     880 <malloc+0xb0>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
 81f:	29 da                	sub    %ebx,%edx
 821:	89 50 04             	mov    %edx,0x4(%eax)
        p += p->s.size;
 824:	8d 04 d0             	lea    (%eax,%edx,8),%eax
        p->s.size = nunits;
 827:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
 82a:	89 0d 60 09 00 00    	mov    %ecx,0x960
      return (void*) (p + 1);
 830:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 833:	83 c4 1c             	add    $0x1c,%esp
 836:	5b                   	pop    %ebx
 837:	5e                   	pop    %esi
 838:	5f                   	pop    %edi
 839:	5d                   	pop    %ebp
 83a:	c3                   	ret    
 83b:	90                   	nop
 83c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < 4096)
 840:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 846:	b8 00 80 00 00       	mov    $0x8000,%eax
 84b:	bf 00 10 00 00       	mov    $0x1000,%edi
 850:	76 04                	jbe    856 <malloc+0x86>
 852:	89 f0                	mov    %esi,%eax
 854:	89 df                	mov    %ebx,%edi
    nu = 4096;
  p = sbrk(nu * sizeof(Header));
 856:	89 04 24             	mov    %eax,(%esp)
 859:	e8 02 fc ff ff       	call   460 <sbrk>
  if(p == (char*) -1)
 85e:	83 f8 ff             	cmp    $0xffffffff,%eax
 861:	74 18                	je     87b <malloc+0xab>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
 863:	89 78 04             	mov    %edi,0x4(%eax)
  free((void*)(hp + 1));
 866:	83 c0 08             	add    $0x8,%eax
 869:	89 04 24             	mov    %eax,(%esp)
 86c:	e8 cf fe ff ff       	call   740 <free>
  return freep;
 871:	8b 0d 60 09 00 00    	mov    0x960,%ecx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
 877:	85 c9                	test   %ecx,%ecx
 879:	75 97                	jne    812 <malloc+0x42>
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
 87b:	31 c0                	xor    %eax,%eax
 87d:	eb b4                	jmp    833 <malloc+0x63>
 87f:	90                   	nop
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
 880:	8b 10                	mov    (%eax),%edx
 882:	89 11                	mov    %edx,(%ecx)
 884:	eb a4                	jmp    82a <malloc+0x5a>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 886:	c7 05 60 09 00 00 58 	movl   $0x958,0x960
 88d:	09 00 00 
    base.s.size = 0;
 890:	b9 58 09 00 00       	mov    $0x958,%ecx
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 895:	c7 05 58 09 00 00 58 	movl   $0x958,0x958
 89c:	09 00 00 
    base.s.size = 0;
 89f:	c7 05 5c 09 00 00 00 	movl   $0x0,0x95c
 8a6:	00 00 00 
 8a9:	e9 45 ff ff ff       	jmp    7f3 <malloc+0x23>
